package edu.hawaii.duedates.wicket;

import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import edu.hawaii.duedates.results.ResultsList;

/**
 * The home page for this DueDates-Polu application.
 * 
 * @author Erin Kim
 */
public class DueDatesList extends DueDatesPage {
  private static final long serialVersionUID = 1L;

  /**
   * Welcome page for patron. Displays the duedates for specified libraries.
   */
  public DueDatesList() {

    // Create the UHM Library Form
    Form uhmForm = new Form("uhmForm");
    uhmForm.add(new Button("updateUhm") {
      private static final long serialVersionUID = 1L;

      @Override
      public void onSubmit() {
        getDueDate().setBannerId("14632718");
        getDueDate().setLastName("kim");
        getDueDate().getUhm = true;
        getDueDate().getHsl = false;
        ResultsList allResults = getDueDate().getAllResults();
        getDueDate().setUhmOutput(allResults.toString());
        setResponsePage(DueDatesList.class);
      }
    });
    
    Form hslForm = new Form("hslForm");
    hslForm.add(new Button("updateHsl") {
      private static final long serialVersionUID = 1L;

      @Override
      public void onSubmit() {
        getDueDate().setPin("3845");
        getDueDate().setBarcode("0011429495");
        getDueDate().getUhm = false;
        getDueDate().getHsl = true;
        ResultsList allResults = getDueDate().getAllResults();
        getDueDate().setHslOutput(allResults.toString());
        setResponsePage(DueDatesList.class);
      }
    });

    
    add(new MultiLineLabel("uhmOutput", getDueDate().getUhmOutput()));
    add(new MultiLineLabel("hlsOutput", getDueDate().getHslOutput()));
    add(uhmForm);
    add(hslForm);

  }

}
